home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / imageio / ImageWriteParam.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  5.3 KB  |  393 lines

  1. package javax.imageio;
  2.  
  3. import java.awt.Dimension;
  4. import java.util.Locale;
  5.  
  6. public class ImageWriteParam extends IIOParam {
  7.    public static final int MODE_DISABLED = 0;
  8.    public static final int MODE_DEFAULT = 1;
  9.    public static final int MODE_EXPLICIT = 2;
  10.    public static final int MODE_COPY_FROM_METADATA = 3;
  11.    private static final int MAX_MODE = 3;
  12.    protected boolean canWriteTiles = false;
  13.    protected int tilingMode = 3;
  14.    protected Dimension[] preferredTileSizes = null;
  15.    protected boolean tilingSet = false;
  16.    protected int tileWidth = 0;
  17.    protected int tileHeight = 0;
  18.    protected boolean canOffsetTiles = false;
  19.    protected int tileGridXOffset = 0;
  20.    protected int tileGridYOffset = 0;
  21.    protected boolean canWriteProgressive = false;
  22.    protected int progressiveMode = 3;
  23.    protected boolean canWriteCompressed = false;
  24.    protected int compressionMode = 3;
  25.    protected String[] compressionTypes = null;
  26.    protected String compressionType = null;
  27.    protected float compressionQuality = 1.0F;
  28.    protected Locale locale = null;
  29.  
  30.    protected ImageWriteParam() {
  31.    }
  32.  
  33.    public ImageWriteParam(Locale var1) {
  34.       this.locale = var1;
  35.    }
  36.  
  37.    private static Dimension[] clonePreferredTileSizes(Dimension[] var0) {
  38.       if (var0 == null) {
  39.          return null;
  40.       } else {
  41.          Dimension[] var1 = new Dimension[var0.length];
  42.  
  43.          for(int var2 = 0; var2 < var0.length; ++var2) {
  44.             var1[var2] = new Dimension(var0[var2]);
  45.          }
  46.  
  47.          return var1;
  48.       }
  49.    }
  50.  
  51.    public Locale getLocale() {
  52.       return this.locale;
  53.    }
  54.  
  55.    public boolean canWriteTiles() {
  56.       return this.canWriteTiles;
  57.    }
  58.  
  59.    public boolean canOffsetTiles() {
  60.       return this.canOffsetTiles;
  61.    }
  62.  
  63.    public void setTilingMode(int var1) {
  64.       if (!this.canWriteTiles()) {
  65.          throw new UnsupportedOperationException("Tiling not supported!");
  66.       } else if (var1 >= 0 && var1 <= 3) {
  67.          this.tilingMode = var1;
  68.          if (var1 == 2) {
  69.             this.unsetTiling();
  70.          }
  71.  
  72.       } else {
  73.          throw new IllegalArgumentException("Illegal value for mode!");
  74.       }
  75.    }
  76.  
  77.    public int getTilingMode() {
  78.       if (!this.canWriteTiles()) {
  79.          throw new UnsupportedOperationException("Tiling not supported");
  80.       } else {
  81.          return this.tilingMode;
  82.       }
  83.    }
  84.  
  85.    public Dimension[] getPreferredTileSizes() {
  86.       if (!this.canWriteTiles()) {
  87.          throw new UnsupportedOperationException("Tiling not supported");
  88.       } else {
  89.          return clonePreferredTileSizes(this.preferredTileSizes);
  90.       }
  91.    }
  92.  
  93.    public void setTiling(int var1, int var2, int var3, int var4) {
  94.       if (!this.canWriteTiles()) {
  95.          throw new UnsupportedOperationException("Tiling not supported!");
  96.       } else if (this.getTilingMode() != 2) {
  97.          throw new IllegalStateException("Tiling mode not MODE_EXPLICIT!");
  98.       } else if (var1 > 0 && var2 > 0) {
  99.          boolean var5 = var3 != 0 || var4 != 0;
  100.          if (!this.canOffsetTiles() && var5) {
  101.             throw new UnsupportedOperationException("Can't offset tiles!");
  102.          } else {
  103.             if (this.preferredTileSizes != null) {
  104.                boolean var6 = true;
  105.  
  106.                for(int var7 = 0; var7 < this.preferredTileSizes.length; var7 += 2) {
  107.                   Dimension var8 = this.preferredTileSizes[var7];
  108.                   Dimension var9 = this.preferredTileSizes[var7 + 1];
  109.                   if (var1 < var8.width || var1 > var9.width || var2 < var8.height || var2 > var9.height) {
  110.                      var6 = false;
  111.                      break;
  112.                   }
  113.                }
  114.  
  115.                if (!var6) {
  116.                   throw new IllegalArgumentException("Illegal tile size!");
  117.                }
  118.             }
  119.  
  120.             this.tilingSet = true;
  121.             this.tileWidth = var1;
  122.             this.tileHeight = var2;
  123.             this.tileGridXOffset = var3;
  124.             this.tileGridYOffset = var4;
  125.          }
  126.       } else {
  127.          throw new IllegalArgumentException("tile dimensions are non-positive!");
  128.       }
  129.    }
  130.  
  131.    public void unsetTiling() {
  132.       if (!this.canWriteTiles()) {
  133.          throw new UnsupportedOperationException("Tiling not supported!");
  134.       } else if (this.getTilingMode() != 2) {
  135.          throw new IllegalStateException("Tiling mode not MODE_EXPLICIT!");
  136.       } else {
  137.          this.tilingSet = false;
  138.          this.tileWidth = 0;
  139.          this.tileHeight = 0;
  140.          this.tileGridXOffset = 0;
  141.          this.tileGridYOffset = 0;
  142.       }
  143.    }
  144.  
  145.    public int getTileWidth() {
  146.       if (!this.canWriteTiles()) {
  147.          throw new UnsupportedOperationException("Tiling not supported!");
  148.       } else if (this.getTilingMode() != 2) {
  149.          throw new IllegalStateException("Tiling mode not MODE_EXPLICIT!");
  150.       } else if (!this.tilingSet) {
  151.          throw new IllegalStateException("Tiling parameters not set!");
  152.       } else {
  153.          return this.tileWidth;
  154.       }
  155.    }
  156.  
  157.    public int getTileHeight() {
  158.       if (!this.canWriteTiles()) {
  159.          throw new UnsupportedOperationException("Tiling not supported!");
  160.       } else if (this.getTilingMode() != 2) {
  161.          throw new IllegalStateException("Tiling mode not MODE_EXPLICIT!");
  162.       } else if (!this.tilingSet) {
  163.          throw new IllegalStateException("Tiling parameters not set!");
  164.       } else {
  165.          return this.tileHeight;
  166.       }
  167.    }
  168.  
  169.    public int getTileGridXOffset() {
  170.       if (!this.canWriteTiles()) {
  171.          throw new UnsupportedOperationException("Tiling not supported!");
  172.       } else if (this.getTilingMode() != 2) {
  173.          throw new IllegalStateException("Tiling mode not MODE_EXPLICIT!");
  174.       } else if (!this.tilingSet) {
  175.          throw new IllegalStateException("Tiling parameters not set!");
  176.       } else {
  177.          return this.tileGridXOffset;
  178.       }
  179.    }
  180.  
  181.    public int getTileGridYOffset() {
  182.       if (!this.canWriteTiles()) {
  183.          throw new UnsupportedOperationException("Tiling not supported!");
  184.       } else if (this.getTilingMode() != 2) {
  185.          throw new IllegalStateException("Tiling mode not MODE_EXPLICIT!");
  186.       } else if (!this.tilingSet) {
  187.          throw new IllegalStateException("Tiling parameters not set!");
  188.       } else {
  189.          return this.tileGridYOffset;
  190.       }
  191.    }
  192.  
  193.    public boolean canWriteProgressive() {
  194.       return this.canWriteProgressive;
  195.    }
  196.  
  197.    public void setProgressiveMode(int var1) {
  198.       if (!this.canWriteProgressive()) {
  199.          throw new UnsupportedOperationException("Progressive output not supported");
  200.       } else if (var1 >= 0 && var1 <= 3) {
  201.          if (var1 == 2) {
  202.             throw new IllegalArgumentException("MODE_EXPLICIT not supported for progressive output");
  203.          } else {
  204.             this.progressiveMode = var1;
  205.          }
  206.       } else {
  207.          throw new IllegalArgumentException("Illegal value for mode!");
  208.       }
  209.    }
  210.  
  211.    public int getProgressiveMode() {
  212.       if (!this.canWriteProgressive()) {
  213.          throw new UnsupportedOperationException("Progressive output not supported");
  214.       } else {
  215.          return this.progressiveMode;
  216.       }
  217.    }
  218.  
  219.    public boolean canWriteCompressed() {
  220.       return this.canWriteCompressed;
  221.    }
  222.  
  223.    public void setCompressionMode(int var1) {
  224.       if (!this.canWriteCompressed()) {
  225.          throw new UnsupportedOperationException("Compression not supported.");
  226.       } else if (var1 >= 0 && var1 <= 3) {
  227.          this.compressionMode = var1;
  228.          if (var1 == 2) {
  229.             this.unsetCompression();
  230.          }
  231.  
  232.       } else {
  233.          throw new IllegalArgumentException("Illegal value for mode!");
  234.       }
  235.    }
  236.  
  237.    public int getCompressionMode() {
  238.       if (!this.canWriteCompressed()) {
  239.          throw new UnsupportedOperationException("Compression not supported.");
  240.       } else {
  241.          return this.compressionMode;
  242.       }
  243.    }
  244.  
  245.    public String[] getCompressionTypes() {
  246.       if (!this.canWriteCompressed()) {
  247.          throw new UnsupportedOperationException("Compression not supported");
  248.       } else {
  249.          return this.compressionTypes == null ? null : (String[])((String[])this.compressionTypes.clone());
  250.       }
  251.    }
  252.  
  253.    public void setCompressionType(String var1) {
  254.       if (!this.canWriteCompressed()) {
  255.          throw new UnsupportedOperationException("Compression not supported");
  256.       } else if (this.getCompressionMode() != 2) {
  257.          throw new IllegalStateException("Compression mode not MODE_EXPLICIT!");
  258.       } else {
  259.          String[] var2 = this.getCompressionTypes();
  260.          if (var2 == null) {
  261.             throw new UnsupportedOperationException("No settable compression types");
  262.          } else {
  263.             if (var1 != null) {
  264.                boolean var3 = false;
  265.                if (var2 != null) {
  266.                   for(int var4 = 0; var4 < var2.length; ++var4) {
  267.                      if (var1.equals(var2[var4])) {
  268.                         var3 = true;
  269.                         break;
  270.                      }
  271.                   }
  272.                }
  273.  
  274.                if (!var3) {
  275.                   throw new IllegalArgumentException("Unknown compression type!");
  276.                }
  277.             }
  278.  
  279.             this.compressionType = var1;
  280.          }
  281.       }
  282.    }
  283.  
  284.    public String getCompressionType() {
  285.       if (!this.canWriteCompressed()) {
  286.          throw new UnsupportedOperationException("Compression not supported.");
  287.       } else if (this.getCompressionMode() != 2) {
  288.          throw new IllegalStateException("Compression mode not MODE_EXPLICIT!");
  289.       } else {
  290.          return this.compressionType;
  291.       }
  292.    }
  293.  
  294.    public void unsetCompression() {
  295.       if (!this.canWriteCompressed()) {
  296.          throw new UnsupportedOperationException("Compression not supported");
  297.       } else if (this.getCompressionMode() != 2) {
  298.          throw new IllegalStateException("Compression mode not MODE_EXPLICIT!");
  299.       } else {
  300.          this.compressionType = null;
  301.          this.compressionQuality = 1.0F;
  302.       }
  303.    }
  304.  
  305.    public String getLocalizedCompressionTypeName() {
  306.       if (!this.canWriteCompressed()) {
  307.          throw new UnsupportedOperationException("Compression not supported.");
  308.       } else if (this.getCompressionMode() != 2) {
  309.          throw new IllegalStateException("Compression mode not MODE_EXPLICIT!");
  310.       } else if (this.getCompressionType() == null) {
  311.          throw new IllegalStateException("No compression type set!");
  312.       } else {
  313.          return this.getCompressionType();
  314.       }
  315.    }
  316.  
  317.    public boolean isCompressionLossless() {
  318.       if (!this.canWriteCompressed()) {
  319.          throw new UnsupportedOperationException("Compression not supported");
  320.       } else if (this.getCompressionMode() != 2) {
  321.          throw new IllegalStateException("Compression mode not MODE_EXPLICIT!");
  322.       } else if (this.getCompressionTypes() != null && this.getCompressionType() == null) {
  323.          throw new IllegalStateException("No compression type set!");
  324.       } else {
  325.          return true;
  326.       }
  327.    }
  328.  
  329.    public void setCompressionQuality(float var1) {
  330.       if (!this.canWriteCompressed()) {
  331.          throw new UnsupportedOperationException("Compression not supported");
  332.       } else if (this.getCompressionMode() != 2) {
  333.          throw new IllegalStateException("Compression mode not MODE_EXPLICIT!");
  334.       } else if (this.getCompressionTypes() != null && this.getCompressionType() == null) {
  335.          throw new IllegalStateException("No compression type set!");
  336.       } else if (!(var1 < 0.0F) && !(var1 > 1.0F)) {
  337.          this.compressionQuality = var1;
  338.       } else {
  339.          throw new IllegalArgumentException("Quality out-of-bounds!");
  340.       }
  341.    }
  342.  
  343.    public float getCompressionQuality() {
  344.       if (!this.canWriteCompressed()) {
  345.          throw new UnsupportedOperationException("Compression not supported.");
  346.       } else if (this.getCompressionMode() != 2) {
  347.          throw new IllegalStateException("Compression mode not MODE_EXPLICIT!");
  348.       } else if (this.getCompressionTypes() != null && this.getCompressionType() == null) {
  349.          throw new IllegalStateException("No compression type set!");
  350.       } else {
  351.          return this.compressionQuality;
  352.       }
  353.    }
  354.  
  355.    public float getBitRate(float var1) {
  356.       if (!this.canWriteCompressed()) {
  357.          throw new UnsupportedOperationException("Compression not supported.");
  358.       } else if (this.getCompressionMode() != 2) {
  359.          throw new IllegalStateException("Compression mode not MODE_EXPLICIT!");
  360.       } else if (this.getCompressionTypes() != null && this.getCompressionType() == null) {
  361.          throw new IllegalStateException("No compression type set!");
  362.       } else if (!(var1 < 0.0F) && !(var1 > 1.0F)) {
  363.          return -1.0F;
  364.       } else {
  365.          throw new IllegalArgumentException("Quality out-of-bounds!");
  366.       }
  367.    }
  368.  
  369.    public String[] getCompressionQualityDescriptions() {
  370.       if (!this.canWriteCompressed()) {
  371.          throw new UnsupportedOperationException("Compression not supported.");
  372.       } else if (this.getCompressionMode() != 2) {
  373.          throw new IllegalStateException("Compression mode not MODE_EXPLICIT!");
  374.       } else if (this.getCompressionTypes() != null && this.getCompressionType() == null) {
  375.          throw new IllegalStateException("No compression type set!");
  376.       } else {
  377.          return null;
  378.       }
  379.    }
  380.  
  381.    public float[] getCompressionQualityValues() {
  382.       if (!this.canWriteCompressed()) {
  383.          throw new UnsupportedOperationException("Compression not supported.");
  384.       } else if (this.getCompressionMode() != 2) {
  385.          throw new IllegalStateException("Compression mode not MODE_EXPLICIT!");
  386.       } else if (this.getCompressionTypes() != null && this.getCompressionType() == null) {
  387.          throw new IllegalStateException("No compression type set!");
  388.       } else {
  389.          return null;
  390.       }
  391.    }
  392. }
  393.